package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.NetworkBillDetail;
import com.ruoyi.logistic.domain.NetworkFeeThroughManage;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.logistic.domain.vo.NetworkFeeThroughManageVo;
import com.ruoyi.logistic.service.NetworkBillDetailService;
import com.ruoyi.logistic.service.NetworkFeeThroughManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Date;
import java.util.List;

@RequestMapping("/network/feeThrough")
@RestController
@Api(tags = "网点财务_派费直达管理")
public class networkFeeThroughManageController {
    @Autowired
    private NetworkFeeThroughManageService networkFeeThroughManageService;

    @ApiOperation("显示派费直达管理")
    @GetMapping("/selectAll")
    public R selectAll(PageDate pageDate){
        List<NetworkFeeThroughManage> networkFeeThroughManageList = networkFeeThroughManageService.selectAll(pageDate);
        if (networkFeeThroughManageList == null || networkFeeThroughManageList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(networkFeeThroughManageList));
        }
    }
    @ApiOperation("添加派费直达管理")
    @PostMapping("/insert")
    public R insert(@RequestBody NetworkFeeThroughManage networkFeeThroughManage){
        Boolean isAdd = networkFeeThroughManageService.insert(networkFeeThroughManage);
        if (isAdd){
            return R.ok("添加成功");
        }else {
            return R.fail("添加失败");
        }
    }
    @ApiOperation("修改派费直达管理")
    @PostMapping("/update")
    public R update(@RequestBody NetworkFeeThroughManage networkFeeThroughManage){
        Boolean isUpdate = networkFeeThroughManageService.update(networkFeeThroughManage);
        if (isUpdate){
            return R.ok("修改成功");
        }else {
            return R.fail("修改失败");
        }
    }
    @ApiOperation("删除派费直达管理")
    @PostMapping("/deleteById")
    public R deleteById(Integer id){
        Boolean isDelete = networkFeeThroughManageService.deleteById(id);
        if (isDelete){
            return R.ok("删除成功");
        }else {
            return R.fail("删除失败");
        }
    }
    @ApiOperation("搜索派费直达管理")
    @PostMapping("/search")
    public R search(@RequestBody NetworkFeeThroughManageVo vo){
        List<NetworkFeeThroughManage> networkFeeThroughManageList = networkFeeThroughManageService.search(vo);

        if (networkFeeThroughManageList == null || networkFeeThroughManageList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(networkFeeThroughManageList));
        }
    }

}
